home *** CD-ROM | disk | FTP | other *** search
/ Columbia Kermit / kermit.zip / e / misc.txt / 000057_fdc@panix.com_Fri Jan 19 13:28:41 2007.msg < prev    next >
Internet Message Format  |  2020-01-01  |  2KB

  1. Path: reader2.panix.com!reader1.panix.com!panix!not-for-mail
  2. From: Frank da Cruz <fdc@panix.com>
  3. Newsgroups: comp.protocols.kermit.misc
  4. Subject: Re: fixed character length with a non-consistant variable length
  5. Date: Fri, 19 Jan 2007 18:28:31 +0000 (UTC)
  6. Organization: PANIX Public Access Internet and UNIX, NYC
  7. Lines: 42
  8. Message-ID: <slrner23eg.nl5.fdc@panix2.panix.com>
  9. References: <qw_rh.2669$1x.45556@ursa-nb00s0.nbnet.nb.ca>
  10. Reply-To: fdc@columbia.edu
  11. NNTP-Posting-Host: panix2.panix.com
  12. X-Trace: reader2.panix.com 1169231311 16272 166.84.1.2 (19 Jan 2007 18:28:31 GMT)
  13. X-Complaints-To: abuse@panix.com
  14. NNTP-Posting-Date: Fri, 19 Jan 2007 18:28:31 +0000 (UTC)
  15. User-Agent: slrn/0.9.8.0 (NetBSD)
  16. Xref: panix comp.protocols.kermit.misc:15629
  17.  
  18. On 2007-01-19, Scott Caissie <scottac@nb.sympatico.ca> wrote:
  19. :
  20. : I'm looking for a "simplier" way to force a variable of mixed character
  21. : length to a fixed character length.
  22. :
  23. : For this project, I always want to have MORE characters than the actual
  24. : variable's size. So I'm trying to add in spaces. Thats my problem. Making
  25. : it less is easy.
  26. :
  27. : Example from my project:
  28. : .q_formatted := \fstripx(\fsubstr(\m(getdata),1,13),\9)
  29. : The saved value has up to 13 characters, but mostly it has less.  For
  30. : testing purposes, I'm trying to fixate the saved character length to 20.
  31. :
  32. You can use \flpad() ("Left Pad") and/or \frpad() ("Right Pad") for this.
  33. For example, suppose that if a string "foo" is less than 20 bytes long, you
  34. want to fill it out on the right with underscores:
  35.  
  36.   .foo := .\frpad(\m(foo),20,_)
  37.  
  38. If the string already is 20 or more bytes long, nothing happens to it.
  39. To fill the string out with spaces, use either one of these forms:
  40.  
  41.   .foo := .\frpad(\m(foo),20,\32)
  42.   .foo := .\frpad(\m(foo),20)
  43.  
  44. : The reasoning for doing this, is that I want to save a multitude of values 
  45. : into 1 entry within an Array. And by it's character position, other macros 
  46. : can determine what the value is represents.
  47. :
  48. You might find some of the programming and data-type extensions presented
  49. here to be useful:
  50.  
  51.   http://www.columbia.edu/kermit/ckscripts.html#oops
  52.  
  53. For example this one:
  54.  
  55.   ftp://kermit.columbia.edu/kermit/scripts/ckermit/matrix
  56.  
  57. shows how to create and use multidimensional arrays.
  58.  
  59. - Frank